<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <link rel="stylesheet" th:href="@{/static/element/index.css}"/>
</head>
<body>
<style>
    .el-input-item{
        width: 260px;
    }

</style>
<div id="app">
    <template>
        <el-form :model="formData" ref="formData" :rules="rules" label-width="100px" style="margin-top: 5%;display: flex;flex-direction: row;align-items: center;flex-wrap: wrap;justify-content: space-between;margin-right: 5%">
                                                                                                                                                                                <el-form-item label="名称" prop="name">
                                <el-input class="el-input-item" size="small" v-model="formData.name" placeholder="请输入名称"/>
                            </el-form-item>
                                                                                                                                                                                                                <el-form-item label="年龄" prop="age">
                                <el-input class="el-input-item" size="small" v-model="formData.age" placeholder="请输入年龄"/>
                            </el-form-item>
                                                                                                                                                                                                                <el-form-item label="状态">
                                <el-select v-model="formData.state" placeholder="请选择状态" class="el-input-item" size="small">
                                    <el-option
                                            v-for="dict in stateOptions"
                                            :key="dict.dictValue"
                                            :label="dict.dictLabel"
                                            :value="parseInt(dict.dictValue)"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                                                                                                            </el-form>
        <div style="text-align: center;margin-top: 5%">
            <el-button size="small" @click="closePage">取 消</el-button>
            <el-button size="small" type="primary" @click="handleSubmit">确 定</el-button>
        </div>
    </template>
</div>
</body>
<script th:src="@{/static/js/axios.min.js}"></script>
<script th:src="@{/static/js/request.js}"></script>
<script th:src="@{/static/js/common.js}"></script>
<script th:src="@{/static/api/apTest1.js}"></script>
<script th:src="@{/static/js/vue.min.js}"></script>
<script th:src="@{/static/element/index.js}"></script>
<script th:src="@{/static/js/jquery.min.js}"></script>
<script th:src="@{/static/layer/layer.js}"></script>
<script>
    let id = getQueryString("id");
    new Vue({
        el: '#app',
        data() {
            return {
                formData: {

                },
                                                                                                    // ID字典
                            idOptions: [],
                                                                                                                        // 名称字典
                            nameOptions: [],
                                                                                                                        // 年龄字典
                            ageOptions: [],
                                                                                                                        // 状态字典
                            stateOptions: [],
                                                                                                                        // 创建时间字典
                            createTimeOptions: [],
                                                    rules: {
                                                                                                                                                                                                                                                                                                                    createTime: [
                                {required: true, message: "创建时间不能为空", trigger: "blur"}
                            ]
                                                            }
            }
        },
        created() {
            if (id) {
                detail(id).then((res) => {
                    if (res.code === '200') {
                        this.formData = res.data
                    }
                });
            } else {
                this.formData = {}
            }
                                                getDicts("${column.dictType}").then(response => {
                        this.idOptions = response.data;
                    });
                                                                getDicts("${column.dictType}").then(response => {
                        this.nameOptions = response.data;
                    });
                                                                getDicts("${column.dictType}").then(response => {
                        this.ageOptions = response.data;
                    });
                                                                getDicts("sys_status").then(response => {
                        this.stateOptions = response.data;
                    });
                                                                getDicts("${column.dictType}").then(response => {
                        this.createTimeOptions = response.data;
                    });
                            
        },
        methods: {
            handleSubmit() {
                if (id) {
                    addOrUpdate('/admin/apTest1/update', this);
                } else {
                    addOrUpdate('/admin/apTest1/add', this);
                }
            }
        }
    });
</script>
</html>
